/*
 * Created on 2005-4-14
 *
 */
package com.hd123.rumba.runtime;

import java.io.Serializable;

import com.hd123.rumba.domain.IDomain;
import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.exception.StringTooLongException;

/**
 * @author caili
 */
public class BaseEntity extends VersionedPersistent implements Serializable, IBaseEntity {
  private IDomain domain;
  private String lastModifier;
  private Integer state;

  /** @deprecated */
  public static final int LENGTH_LASTMODIFIER = CBaseEntity.LENGTH_LASTMODIFIER;

  public IDomain getDomain() {
    return domain;
  }

  public void setDomain(IDomain domain) {
    this.domain = domain;
  }

  public String getLastModifier() {
    return lastModifier;
  }

  public void setLastModifier(String lastModifier) throws StringTooLongException {
    if (lastModifier != null) {
      lastModifier = CPersistent.truncate(lastModifier, CBaseEntity.LENGTH_LASTMODIFIER,
          "lastModifier", CBaseEntity.CAPTION_LASTMODIFIER);
    }
    this.lastModifier = lastModifier;
  }

  public Integer getState() {
    return state;
  }

  public void setState(Integer state) {
    this.state = state;
  }

  public void assign(IBaseEntity obj) throws BusinessException {
    super.assign(obj);
    this.setDomain(obj.getDomain());
    this.setLastModifier(obj.getLastModifier());
    this.setState(obj.getState());
  }
}
